Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

10074 bug: Auto Scroll Issues on Petitions Clerk Create Case Form (and more) #5382

Merged
merged 35 commits into from
Sep 24, 2024

Conversation

Mwindo
Copy link
Contributor

@Mwindo Mwindo commented Sep 19, 2024

TL;DR: Fixing some quite a few form validation bugs/quirks.


The goals of this PR:

  • Fix a couple of bugs
  • When applicable, update ErrorNotification live to keep it in sync with in-line validations. (The previous behavior had ErrorNotification only updating on submissions, not validations.)
  • Refactor to make validation slightly more consistent across the app and to eliminate duplicative actions (namely, setAlertErrorAction followed by setValidationAlertErrorsAction).

In the future, we will probably move away from the ErrorNotification altogether--similar to how things work with the new petitioner flow--but this at least keeps behavior consistent until then and hopefully will make a refactor easier.


An outline of the issues addressed:

  1. After (almost) every field edit on the petitions clerk create case form, we were scrolling back to the ErrorNotification banner. (This was the original error of 10074).
    2. In certain cases on the petitions clerk create case form, the form scrolled weirdly. (This was design debt 10357.) Not fixed!
  2. In the PetitionsPayment forms, blank Payment Dates and Payment Methods led to 400 errors rather than validation errors. (See video below.)
Screen.Recording.2024-09-20.at.1.50.00.PM.mov
  1. Certain onBlurs/onChanges weren't providing live validation. (E.g., Status Report Order validation was not providing live validation updates.) There are probably still some that I have missed.

Comment on lines +21 to +22
petitionPaymentDate: form.petitionPaymentDate || null,
petitionPaymentMethod: form.petitionPaymentMethod || null,
Copy link
Contributor Author

@Mwindo Mwindo Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes issue 2 as listed in the PR description by triggering the validation rather than allowing the form to pass and then cause a 400.

if (isEmpty(errors)) {
return path.success();
} else {
return path.error({ errors });
return path.error({ errors: { contact: errors } });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way this action was functioning was failing to update the corresponding form (EditPetitionerInformationInternal.tsx) appropriately.

@@ -15,7 +15,6 @@ export const alertHelper = (get: Get): any => {

return {
messagesDeduped: uniq(alertError.messages).filter(Boolean),
preventAutoScroll: false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useless since it is always false.

@@ -86,6 +86,7 @@ export const setValidationAlertErrorsAction = ({
}
}),
),
scrollToErrorNotification: props.scrollToErrorNotification || false,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This gives us a way explicitly telling the app when to scroll to the ErrorNotification banner. By default, we don't scroll. To change the default, we can call the above setScrollToErrorNotificationAction.

@@ -27,8 +27,8 @@ export const submitJudgeActivityReportSequence = showProgressSequenceDecorator([
validateJudgeActivityReportSearchAction,
{
error: [
setAlertErrorAction,
Copy link
Contributor Author

@Mwindo Mwindo Sep 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throughout, I have removed setAlertErrorAction when it precedes setValidationAlertErrorsAction since the latter overwrites the former. On submissions, I have called setScrollToErrorNotificationsAction. A good portion of this PR is refactoring sequences to follow this pattern.

@Mwindo Mwindo added the to test label Sep 23, 2024
@Mwindo Mwindo changed the title 10074 bug: Auto Scroll Issues on Petitions Clerk Create Case Form 10074 bug: Auto Scroll Issues on Petitions Clerk Create Case Form (and more) Sep 23, 2024
@@ -534,7 +534,7 @@ export class Case extends JoiValidationEntity {
mailingDate: JoiValidationConstants.STRING.max(25)
.when('isPaper', {
is: true,
otherwise: joi.allow(null).optional(),
otherwise: joi.optional().allow(null),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just making the order of these consistent in the file.

@Mwindo Mwindo marked this pull request as ready for review September 23, 2024 13:35
Copy link
Contributor

@En-8 En-8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM :)

@@ -140,4 +141,23 @@ describe('setValidationAlertErrors', () => {
messages: ['second nested', 'first nested'],
});
});

it('state.alertError sets scrollToErrorNotification appropriately', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this doesn't really read like a sentence ("it does x [when y]") the same way our other test cases do.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right--I will update! Thanks :)

@Mwindo Mwindo merged commit 62892f6 into ustaxcourt:test Sep 24, 2024
44 checks passed
@Mwindo Mwindo mentioned this pull request Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants